<template>
    <a-form-model :label-col="{ span: 4 }" :wrapper-col="{ span: 12 }">
        <a-form-model-item label="营业执照号">
            <a-input v-model="info.business_license_no"></a-input>
        </a-form-model-item>
        <a-form-model-item label="有效期">
            <a-input v-model="info.valid_period"></a-input>
        </a-form-model-item>

        <img src="item" alt="" v-for="item in  images" >
        <a-form-model-item label="营业执照">
            <a-upload
                list-type="picture-card"
                class="avatar-uploader"
                :show-upload-list="false"
                :action="$api.sellerConfigs+'/upload/images'"
                :data="{token:$getSession('token_type'),name:'business_license'}"
                @change="upload"
            >
                <img v-if="info.business_license" width="220px" height="220px" :src="info.business_license" />
                <div v-else>
                    <a-font v-if="!loading" type='iconplus' />
                    <a-icon v-else type="loading" />
                </div>
            </a-upload>
        </a-form-model-item>

        <a-form-model-item label="一般人纳税证明">
            <a-upload
                list-type="picture-card"
                class="avatar-uploader"
                :show-upload-list="false"
                :action="$api.sellerConfigs+'/upload/images'"
                :data="{token:$getSession('token_type'),name:'general_taxpayer_certificate'}"
                @change="upload1"
            >
                <img v-if="info.general_taxpayer_certificate" width="220px" height="220px" :src="info.general_taxpayer_certificate" />
                <div v-else>
                    <a-font v-if="!loading" type='iconplus' />
                    <a-icon v-else type="loading" />
                </div>
            </a-upload>
        </a-form-model-item>
        <a-form-model-item :wrapper-col="{ span: 12, offset: 4 }">
            <a-button type="primary" @click="handleSubmit">提交</a-button>
        </a-form-model-item>
    </a-form-model>
</template>

<script>
export default {
    components: {},
    props: {},
    data() {
      return {
          info:{},
          loading:false,
          images: []
      };
    },
    watch: {},
    computed: {},
    methods: {
        handleSubmit(){
            this.info.edit_type = 'face';
            this.$put(this.$api.sellerConfigs,this.info).then(res=>{
                this.get_info();
                return this.$returnInfo(res);
            })
        },
        upload(e){
            if(e.file.status == 'done'){
                this.loading = false;
                let rs = e.file.response;
                if(rs.code == 200){
                    this.$set(this.info,'business_license',rs.data);
                }else{
                    return this.$message.error(rs.msg);
                }
            }else{
                this.loading = true;
            }

        },
        upload1(e){

            if(e.file.status == 'done'){
                this.loading = false;
                let rs = e.file.response;
                if(rs.code == 200){
                    this.$set(this.info,'general_taxpayer_certificate',rs.data);
                }else{
                    return this.$message.error(rs.msg);
                }
            }else{
                this.loading = true;
            }
        },
        get_info(){
            this.$get(this.$api.sellerConfigs).then(res=>{
                this.info = res.data;
            })
        }
    },
    created() {
        this.get_info();
    },
    mounted() {}
};
</script>
<style lang="scss" scoped>

</style>
